package com.xintonghua.bussiness.ui.home;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Point;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.xintonghua.bussiness.R;
import com.xintonghua.bussiness.base.BaseActivity;
import com.xintonghua.bussiness.ui.view.DrawView;
import com.xintonghua.bussiness.util.JumpUtils;

import java.io.Serializable;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by liqi on 2018/3/28.
 */

public class DialogMemeberSignActivity extends BaseActivity {

    @BindView(R.id.dv_drawview)
    DrawView dvDrawview;
    @BindView(R.id.btn_cancel)
    Button btnCancel;
    @BindView(R.id.btn_clear)
    Button btnClear;
    @BindView(R.id.btn_ok)
    Button btnOk;
    @BindView(R.id.tv_title_m)
    TextView tvTitleM;
    @BindView(R.id.tv_msg_m)
    TextView tvMsgM;


    String title;
    String msg;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dialog_memebersign);
        ButterKnife.bind(this);
        title = JumpUtils.getString(this, "title");
        msg = JumpUtils.getString(this, "msg");

        if (!TextUtils.isEmpty(title)) {
            tvTitleM.setText("" + title);
        }

        if (!TextUtils.isEmpty(msg)) {
            tvMsgM.setVisibility(View.VISIBLE);
            tvMsgM.setText("" + msg);
        }

    }

    @OnClick({R.id.btn_cancel, R.id.btn_clear, R.id.btn_ok})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_cancel:
                finish();
                break;
            case R.id.btn_clear:
                dvDrawview.clearView();
                break;
            case R.id.btn_ok:
                List<Point> list = dvDrawview.getPlist();
                Intent intent = new Intent();
                intent.putExtra("data", (Serializable) list);
                intent.putExtra("width", dvDrawview.getWidth());
                intent.putExtra("height", dvDrawview.getHeight());
                setResult(Activity.RESULT_OK, intent);
                finish();
                break;
        }
    }
}
